$(document).ready(function() {

	alert('test validate');

$("#form1").validate({
		
			
		submitHandler: function() {
			alert("txt1="+document.getElementById("txt1").value);
			alert("submitted!22");
			//$('#dialog-confirm').dialog('open');
			form.submit();
		},
				
		rules: {
			txt1: "required",
			docDate: "required",
			iTTL_deptPay: "required",
			projectCode1: "required",
			itemCode1: "required",
			itemCode2: "required",
			itemCode3: "required",
			itemCode4: "required",
			itemCode5: "required",
			
			itemCode6: "required",
			itemCode7: "required",
			itemCode8: "required",
			itemCode9: "required",
			itemCode10: "required",
			itemCode11: "required",
			itemCode12: "required",
			itemCode13: "required",
			itemCode14: "required",
			itemCode15: "required",
			itemCode16: "required",
			itemCode17: "required",
			itemCode18: "required"
			
						
		},
		messages: {
			txt1: "*",
			docDate: "*",
			iTTL_deptPay: "*",
			projectCode: "*",
			itemCode1: "*",
			itemCode2: "*",				
			itemCode3: "*",
			itemCode4: "*",
			itemCode5: "*",

			itemCode6: "required",
			itemCode7: "required",
			itemCode8: "required",
			itemCode9: "required",
			itemCode10: "required",
			itemCode11: "required",
			itemCode12: "required",
			itemCode13: "required",
			itemCode14: "required",
			itemCode15: "required",
			itemCode16: "required",
			itemCode17: "required",
			itemCode18: "required"			
		},

		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			//alert("errorPlacement");			
			if ( element.is(":radio") ) {
				alert("radio");
				error.appendTo( element.parent().next().next() );
			}else if ( element.is(":checkbox") ) {
				alert("checkbox");
				error.appendTo ( element.next() );
			}else {
				/*alert(element("#itemCode1"));
				if(element.is("#itemCode1")) {
					error.appendTo( "#qty1-error" );
				}else {
					error.appendTo( element.parent().next() );	
				}*/
				//error.insertAfter('#qty1-error');
				error.appendTo( element.parent().next() );
			}
		}		
	});

});